import java.util.Scanner;

public class ticketsSystem {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份");
        int count=1;
        while (true){
            int a = 0;
            try {
                a = scanner.nextInt();
            } catch (Exception e) {
                count++;
                System.out.println("输入的月份非整数,,只有五次机会,这是第"+(count-1)+"次");
                if (count == 6){
                    System.out.println("已输错5次,程序即将退出");
                    break;
                }
                scanner.next();
                continue;
            }
            if(a<1 || a>12) {
                System.out.println("月份最小为1或大于12,请输入正确的月份");
            }else if (a>=4 && a<=10){
                System.out.println("旺季");
                System.out.println("请输入年龄");
                int b = scanner.nextInt();
                if (b<18){
                    System.out.println("儿童票价30");
                }if (b>60){
                    System.out.println("老年票20");
                }if(b>=18 || b<=60){
                    System.out.println("成人票60");
                }
            }else if (a<4 || a>10){
                System.out.println("请输入年龄");
                int b = scanner.nextInt();
                System.out.println("淡季");
                if (b<18 || b>60){
                    System.out.println("老人及儿童20");
                }if(b>=18 || b<=60){
                    System.out.println("成人票40");
                }
            }
            System.out.println("是否继续查询?"+"\n继续查询请输入数字 1,退出查询请输入数字 2");
            int command = scanner.nextInt();
            if (command ==1){
                System.out.println("请输入月份");
            }
            if (command == 2){
                System.out.println("====程序结束====");
                break;
            }
        }
    }
}
